//饼图
/*var pielData=[
            {value:335, name:'公检法'},
            {value:310, name:'外交'},
            {value:234, name:'部委'}
      ]

var legendDataL=function(data){
	var arr=[];
	for(var i=0;i<data.length;i++){
		arr.push(data[i].name)
	}
	return arr
}
pieOptionL = {
	color : ["#09e24b","#09e2cb","#09a7e2","#fce24f","#b8ff2e", "#68059c","#0841b6","#9c0550"],
    title : {
    		show:false,
        text: '某站点用户访问来源',
        subtext: '纯属虚构',
        x:'center'
    },
    tooltip : {
        trigger: 'item',
        formatter: "{a} <br/>{b} : {c} ({d}%)"
    },
    legend: {
        orient: 'horizontal',
        left: 'center',
        bottom:'15',
        textStyle:{
        	color: '#fff'
        },
        data: legendDataL(pielData)
    },
    series : [
        {
            name: '网站数量',
            type: 'pie',
            radius : ['40%','55%'],
            center: ['50%', '40%'],
            data:pielData,
            itemStyle: {
                emphasis: {
                    shadowBlur: 10,
                    shadowOffsetX: 0,
                    shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
            }
        }
    ]
};

var pieChart = echarts.init(document.getElementById('ec_pie_nd'))
pieChart.setOption(pieOptionL);*/


//折线图
function lineEvt(timeData,data1,ele){
	var lineOption = {
		color : ["#0ea4e3","#0edf4d"],
		    tooltip : {
		        trigger: 'item',
		        /*backgroundColor: 'rgba(22,189,7,0.3)',
		        borderWidth: 1,
		        borderColor: 'rgba(22,189,7,0.8)',
		        textStyle: {
		            color: '#16d804'
		        },*/
		    },
		    grid: {
		        top:'8%',
		        left: '3%',
		        right: '3%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis: {
//		        boundaryGap : false,
		        type: 'category',
		        splitLine:{    //grid区域分隔线
		            show:true,
		            lineStyle: {
		                width:1,
		                type:"dashed",
		                color:"#48484a"
		            }
		        },
		        axisLabel: {  //坐标轴标签
		            show: true,
		            textStyle: {
		                color: '#0d7790'
		            },
		            rotate : 45,
		            interval:false
		        },
		        axisTick: {
		            show: false   //刻度线
		        },
		        axisLine:{
		            show: true,   //坐标轴轴线
		            lineStyle: {
		                width:1,
		                color:"#fff"
		            }
		        },
		        data : timeData
		    },
		    yAxis : {
		    	name : '单位/亿',
		        splitLine:{    //grid区域分隔线
		            show:true,
		            lineStyle: {
		                width:1,
		                type:"dashed",
		                color:"#1a1a1b"
		            }
		        },
		        axisTick: {
		            show: false   //刻度线
		        },
		        axisLine: {
		            show: true ,  //坐标轴轴线
		            lineStyle: {
		                width:1,
		                color:"#fff"
		            }
		        },
		        axisLabel: {  //坐标轴标签
		            show: true
		        },
		    },
		    series : [
		        {
		            name:'数量',
		            type:'bar',
		            symbol:'none',  //这句就是去掉点的
		            stack: '总量',
		            barWidth: '50%',
		            smooth: true,
		            itemStyle: { normal: {
//		                color:'#20fd07',
		            }},
		            lineStyle: { normal: {
		                color:'#20fd07',
		            }},
		            areaStyle: {
		                normal: {
//		                    color:'#20fd07',
		                    opacity: 0.08
		                }
		            },
		            data:data1
		        }
		    ]
		};
		var lineChart = echarts.init(document.getElementById(ele))
		lineChart.setOption(lineOption);
		window.addEventListener("resize", function () {
		    lineChart.resize();
		});
}

function lineEvt1(timeData,data1,ele){
	var lineOption = {
		color : ["#0ea4e3","#0edf4d"],
		    tooltip : {
		        trigger: 'item',
		        /*backgroundColor: 'rgba(22,189,7,0.3)',
		        borderWidth: 1,
		        borderColor: 'rgba(22,189,7,0.8)',
		        textStyle: {
		            color: '#16d804'
		        },*/
		    },
		    grid: {
		        top:'8%',
		        left: '3%',
		        right: '3%',
		        bottom: '3%',
		        containLabel: true
		    },
		    xAxis: {
//		        boundaryGap : false,
		        type: 'category',
		        splitLine:{    //grid区域分隔线
		            show:true,
		            lineStyle: {
		                width:1,
		                type:"dashed",
		                color:"#48484a"
		            }
		        },
		        axisLabel: {  //坐标轴标签
		            show: true,
		            textStyle: {
		                color: '#0d7790'
		            },
		            rotate : 25,
		            //interval:false
		        },
		        axisTick: {
		            show: false   //刻度线
		        },
		        axisLine:{
		            show: true,   //坐标轴轴线
		            lineStyle: {
		                width:1,
		                color:"#fff"
		            }
		        },
		        data : timeData
		    },
		    yAxis : {
		        splitLine:{    //grid区域分隔线
		            show:true,
		            lineStyle: {
		                width:1,
		                type:"dashed",
		                color:"#1a1a1b"
		            }
		        },
		        axisTick: {
		            show: false   //刻度线
		        },
		        axisLine: {
		            show: true ,  //坐标轴轴线
		            lineStyle: {
		                width:1,
		                color:"#fff"
		            }
		        },
		        axisLabel: {  //坐标轴标签
		            show: true
		        },
		    },
		    series : [
		        {
		            name:'数量',
		            type:'bar',
		            symbol:'none',  //这句就是去掉点的
		            stack: '总量',
		            barWidth: '50%',
		            smooth: 'true',
		            itemStyle: { normal: {
//		                color:'#20fd07',
		            }},
		            lineStyle: { normal: {
		                color:'#20fd07',
		            }},
		            areaStyle: {
		                normal: {
//		                    color:'#20fd07',
		                    opacity: 0.08
		                }
		            },
		            data:data1
		        }
		    ]
		};
		var lineChart = echarts.init(document.getElementById(ele))
		lineChart.setOption(lineOption);
		window.addEventListener("resize", function () {
		    lineChart.resize();
		});
}
var timeData1= ['广东移动','重庆联通','山东联通','北京联通','福建联通','湖南联通','山东电信','湖北电信','广西移动','天津联通']
var data1=[2816, 2659, 2586, 2520,2106, 2100, 1850, 1621, 1510, 1302]
lineEvt(timeData1,data1,"ec_line_nd")

var timeData2= ['山东','广东','北京','重庆','福建','湖南','浙江','广西','湖北','四川']
var data2=[3979,3459,3227,2673,2563,2508,2072,2055,1705,1424]
lineEvt1(timeData2,data2,"ec_pie_nd")

//地图

	//var color = ['#a6c84c', '#ffa022', '#46bee9'];
	
//var provinces = {
//  '上海': './echarts/mapJson/data-1482909900836-H1BC_1WHg.json',
//  '河北': './echarts/mapJson/data-1482909799572-Hkgu_yWSg.json',
//  '山西': './echarts/mapJson/data-1482909909703-SyCA_JbSg.json',
//  '内蒙古': './echarts/mapJson/data-1482909841923-rkqqdyZSe.json',
//  '辽宁': './echarts/mapJson/data-1482909836074-rJV9O1-Hg.json',
//  '吉林': './echarts/mapJson/data-1482909832739-rJ-cdy-Hx.json',
//  '黑龙江': './echarts/mapJson/data-1482909803892-Hy4__J-Sx.json',
//  '江苏': './echarts/mapJson/data-1482909823260-HkDtOJZBx.json',
//  '浙江': './echarts/mapJson/data-1482909960637-rkZMYkZBx.json',
//  '安徽': './echarts/mapJson/data-1482909768458-HJlU_yWBe.json',
//  '福建': './echarts/mapJson/data-1478782908884-B1H6yezWe.json',
//  '江西': './echarts/mapJson/data-1482909827542-r12YOJWHe.json',
//  '山东': './echarts/mapJson/data-1482909892121-BJ3auk-Se.json',
//  '河南': './echarts/mapJson/data-1482909807135-SJPudkWre.json',
//  '湖北': './echarts/mapJson/data-1482909813213-Hy6u_kbrl.json',
//  '湖南': './echarts/mapJson/data-1482909818685-H17FOkZSl.json',
//  '广东': './echarts/mapJson/data-1482909784051-BJgwuy-Sl.json',
//  '广西': './echarts/mapJson/data-1482909787648-SyEPuJbSg.json',
//  '海南': './echarts/mapJson/data-1482909796480-H12P_J-Bg.json',
//  '四川': './echarts/mapJson/data-1482909931094-H17eKk-rg.json',
//  '贵州': './echarts/mapJson/data-1482909791334-Bkwvd1bBe.json',
//  '云南': './echarts/mapJson/data-1482909957601-HkA-FyWSx.json',
//  '西藏': './echarts/mapJson/data-1482927407942-SkOV6Qbrl.json',
//  '陕西': './echarts/mapJson/data-1482909918961-BJw1FyZHg.json',
//  '甘肃': './echarts/mapJson/data-1482909780863-r1aIdyWHl.json',
//  '青海': './echarts/mapJson/data-1482909853618-B1IiOyZSl.json',
//  '宁夏': './echarts/mapJson/data-1482909848690-HJWiuy-Bg.json',
//  '新疆': './echarts/mapJson/data-1482909952731-B1YZKkbBx.json',
//  '北京': './echarts/mapJson/data-1482818963027-Hko9SKJrg.json',
//  '天津': './echarts/mapJson/data-1482909944620-r1-WKyWHg.json',
//  '重庆': './echarts/mapJson/data-1482909775470-HJDIdk-Se.json',
//  '香港': './echarts/mapJson/data-1461584707906-r1hSmtsx.json',
//  '澳门': './echarts/mapJson/data-1482909771696-ByVIdJWBx.json'
//};	
var geoCoordMap={}
var mapFeatures = echarts.getMap('china').geoJson.features;
mapFeatures.forEach(function(v) {
    // 地区名称
    var name = v.properties.name;
    // 地区经纬度
    geoCoordMap[name] = v.properties.cp;
});

var convertData = function (data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name];
        if (geoCoord) {
            res.push({
                name: data[i].name,
                value: geoCoord.concat(data[i].value)
            });
        }
    }
    return res;
};
var mapData=[
	{name:'山东',value:3979},
	{name:'广东',value:3459},
	{name:'北京',value:3227},
	{name:'重庆',value:2673},
	{name:'福建',value:2563},
	{name:'湖南',value:2508},
	{name:'广西',value:2055},
	{name:'湖北',value:1705},
	{name:'四川',value:1424},
	{name:'天津',value:1370},
	{name:'上海',value:1132},
	{name:'江苏',value:994},
	{name:'云南',value:871},
	{name:'陕西',value:767},
	{name:'安徽',value:668},
	{name:'新疆',value:640},
	{name:'浙江',value:521},
	{name:'河北',value:435},
	{name:'海南',value:327},
	{name:'甘肃',value:310},
	{name:'河南',value:292},
	{name:'江西',value:280},
	{name:'吉林',value:264},
	{name:'黑龙江',value:199},
	{name:'贵州',value:183},
	{name:'宁夏',value:161},
	{name:'辽宁',value:133},
	{name:'山西',value:93},
	{name:'内蒙古',value:76},
	{name:'青海',value:58},
	{name:'西藏',value:29},
	{name: '台湾',value: 0 },
	{name: '香港',value: 0 },
	{name: '澳门',value: 0 }
]
	
var optionMap = {
	tooltip: {
		trigger: 'item',
		formatter:function(param){
//			console.log(param)
			return '<div>'+param.name+'</div>'+
			       '<div>网站数：'+param.data.value[2]+'</div>';
		}
	},
	geo: {
		show: true,
		zoom: 1.2,
		roam: false,
		map: 'china',
		itemStyle: {
			normal: {
				show: false,
				borderColor: '#285ac6',
				borderWidth: 1,
				areaColor: '#123082',
				shadowBlur: 3,
				shadowColor: '#081435',
				shadowOffsetX: -4,
				shadowOffsetY: 8
			},
			emphasis: {
				areaColor: '#fce24f',
				borderColor: '#fce24f'
			}
		}
	},
	series: [{
				type: 'map',
					zoom: 1.2,
					mapType: 'china',
					//		geoIndex: 0,
					roam: false,
					label: {
						normal: {
							show: false,
							textStyle: {
								color: '#fff'
							}
						},
						emphasis: {
							show: true,
							textStyle: {
								color: '#fff'
							}
						}
					},
					itemStyle: {
						normal: {
							show: false,
							borderColor: '#3770ea',
							borderWidth: 1,
							areaColor: '#0f2d87'
						},
						emphasis: {
							areaColor: '#2a56bd',
							borderColor: '#2a56bd',
							//				opacity: 0.8,
						}
					},
				data:convertData(mapData)
			},{
			 	name: 'Top 5',
	      type: 'effectScatter',
	      zlevel: 1,
	      coordinateSystem: 'geo',
	      symbolSize: function (val) {
	          return val[2]/3979*15+5
	      },
	      showEffectOn: 'render',
	      rippleEffect: {
	          brushType: 'stroke'
	      },
	      hoverAnimation: true,
	      label: {
	          normal: {
	//            formatter: '{b}',
			        position: 'right',
			        show: false
	          }
	      },
	      itemStyle: {
	          normal: {
	              color: '#f4e925',
	              shadowBlur: 10,
	              shadowColor: '#333'
	          }
	      },
	//    data: convertData(mapData)
				data:convertData(mapData.sort(function(a,b){
					return b.value-a.value
				}).slice(0,5))
			},{
			 	name: 'Top 5',
	      type: 'scatter',
	      zlevel: 1,
	      coordinateSystem: 'geo',
	      symbolSize: function (val) {
	//        return val*4+8;
					return val[2]/3979*15+5
	      },
	      showEffectOn: 'render',
	      rippleEffect: {
	          brushType: 'stroke'
	      },
	      hoverAnimation: true,
	      label: {
	          normal: {
	//            formatter: '{b}',
			        position: 'right',
			        show: false
	          }
	      },
	      itemStyle: {
	          normal: {
	              color: '#f4e925',
	              shadowBlur: 10,
	              shadowColor: '#333'
	          }
	      },
	//    data: convertData(mapData)
				data:convertData(mapData.sort(function (a, b) {
	          return b.value - a.value;
	      }).slice(5))
			}]
};

var mapChart = echarts.init(document.getElementById('ec_map_nd'))
mapChart.setOption(optionMap)
//地图点击跳转

//mapChart.on('click',function(params){
//	console.log($(".home"))
//	$(".map_open").show();
//	$(".map_close").addClass('zoomIn animated')
//	$(".map_open iframe").removeClass('zoomOut animated').addClass("zoomIn animated");
//})
//$(".map_close").click(function(){
//	$(".map_open").fadeOut();
//	$(".map_open iframe").removeClass('zoomIn animated').addClass("zoomOut animated");
//})
//mapChart.on('click',function(param){
////	console.log(param)
//	var selectedProvince = param.name;
////	console.log(selectedProvince)
////	if(param.seriesName==='选择器'){
////		console.log(selectedProvince)
////	}
//	if(param.seriesName==='选择器'){
//		optionMap.series[0].mapType ='china';
//		mapChart.setOption(optionMap, true);
//	}
//	$.get(provinces[selectedProvince], function(geoJson) {
//		echarts.registerMap(selectedProvince, geoJson);
////		console.log(selectedProvince)
//		optionMap.series[0].mapType =selectedProvince;
//		console.log(selectedProvince)
//		optionMap.series[1].data=[{name:selectedProvince,selected:true}],
//		optionMap.series[1].roam=false
//		mapChart.setOption(optionMap, true);
//	});
//})

//柱状图
/*var timeData= ['广东移动','山东联通','北京联通','重庆联通','福建联通','湖南联通','山东电信','广西移动','湖北电信','金湖县创联科技']
var data1=[2264,2158,2139,1908,1876,1762,1518,1216,1146,1131]
var data2=[120, 182, 301, 234, 190, 150, 110, 202, 201, 364]
var barOption = {
    color : ["#0ea4e3","#0edf4d"],
    tooltip : {
//      trigger: 'axis',
    },
    grid: {
        top:20,
        left: '0%',
        right: '3%',
        bottom: 20,
        containLabel: true
    },
    xAxis: {
//      boundaryGap : false,
        type: 'category',
        splitLine:{    //grid区域分隔线
            show:false,
            lineStyle: {
                width:1,
                type:"solid",
                color:"#2a3f7e"
            }
        },
        axisLabel: {  //坐标轴标签
            show: true,
            interval:false,
            rotate : 30,//310横轴字体倾斜度
            textStyle: {
                color: '#0d7790'
            }
        },
        axisTick: {
            show: true,   //刻度线
            color:"#c0d4da"
        },
        axisLine:{
            show: true,   //坐标轴轴线
            lineStyle: {
                width:1,
                color:"#c0d4da"
            }
        },
        data : timeData
    },
    yAxis : {
        splitLine:{    //grid区域分隔线
            show:true,
            lineStyle: {
                width:1,
                type:"solid",
                color:"#2a3f7e"
            }
        },
        axisTick: {
            show: true   //刻度线
        },
        axisLine: {
            show: true ,  //坐标轴轴线
            lineStyle: {
                width:1,
                color:"#c0d4da"
            }
        },
        axisLabel: {  //坐标轴标签
            show: true,
            color:'#c0d4da'
        },
    },
    series : [
        {
            name:'网站数量',
            type:'bar',
            barWidth:'50%',
            symbol:'none',  //这句就是去掉点的
            lineStyle: { normal: {
                color:'#1de5f2',
            }},
            areaStyle: {
                normal: {
                    color:'#1de5f2',
                    opacity: 0.2
                }
            },
            data:data1
        }
    ]
	}

var barChart = echarts.init(document.getElementById('rightBar'))
barChart.setOption(barOption);*/

ranklistRight1Data();
ranklistRight2Data();
function ranklistRight2Data(){
	var ranklistRight2 = $('#ranklistRight2');
	ranklistRight2.empty();
	var datas = [
		['gov.cn','京ICP备05070218号','国务院办公厅','北京',38578.1,'上升'],
		['wuhu.gov.cn','皖ICP备05013598号-1','芜湖市人民政府信息化办公室','安徽',11.5,'下降'],
		['leshan.gov.cn','蜀ICP备12011101号-1','乐山市人民政府办公室','四川',9.72,'上升'],
		['gaoming.gov.cn','粤ICP备11067329号-1','佛山市高明区人民政府办公室','广东',5.41,'上升'],
		['moe.gov.cn','京ICP备10028400号-1','中华人民共和国教育部','北京',5.37,'下降'],
		['forestry.gov.cn','京ICP备10047111号-4','国家林业局','北京',5.10,'上升'],
		['gxxl.gov.cn','桂ICP备11006435号-5','中国共产党西林县委员会宣传部','广西',4.72,'上升'],
		['xa.gov.cn','陕ICP备05011550号-1','西安市人民政府','陕西',3.91,'上升'],
		['cqjlp.gov.cn','渝ICP备14002057号-1','重庆市九龙坡区人民政府办公室','重庆',3.32,'上升'],
		['yinchuan.gov.cn','宁ICP备17000118号-2','银川市人民政府办公厅','宁夏',2.87,'上升'],
	];
	var str = "<table class='tab_content'>";
	for(var i = 0 ; i < datas.length ; i++){
		var type = datas[i][5];
		var style = '';
		if(type == '上升'){
			style = 'up';
		}else{
			style = 'down';
		}
		str +="<tr>"+
		"<td title='"+datas[i][0]+"'>"+datas[i][0]+"</td>"+
    	"<td title='"+datas[i][1]+"'>"+datas[i][1]+"</td>"+
    	"<td title='"+datas[i][2]+"'>"+datas[i][2]+"</td>"+
    	"<td title='"+datas[i][3]+"'>"+datas[i][3]+"</td>"+
    	"<td title='"+datas[i][4]+"'>"+datas[i][4]+"</td>"+
    	"<td><div class="+style+"></div></td>"+
    	"</tr>"
	}
	str +="</table>";
	ranklistRight2.append(str);
}

function ranklistRight1Data(){
	var ranklistRight1 = $('#ranklistRight1');
	ranklistRight1.empty();
	var datas = [
		['中国政府网_中央人民政府门户网站','gov.cn',38578.1],
		['“中国·东莞”政府门户网站','dg.gov.cn',157.45],
		['中国德庆-政府网欢迎您！','deqing.gd.cn',67.23],
		['马鞍山市人民政府','mas.gov.cn',62.81],
		['湘西自治州人民政府','xxz.gov.cn',58.36],
		['佛山市人民政府门户网站','foshan.gov.cn',31.82],
		['中国广州政府门户网站','gz.gov.cn',21.07],
		['中国.钟山信息网>>了解钟山的窗口','gxzs.gov.cn',19.86],
		['渭南市人民政府','weinan.gov.cn',18.49],
		['欢迎光临肇庆市人民政府！','zhaoqing.gov.cn',14.54],
	];
	var str = "<table class='tab_content'>";
	for(var i = 0 ; i < datas.length ; i++){
		str +="<tr>"+
		"<td style='width:50px;'>"+(i+1)+"</td>"+
    	"<td title='"+datas[i][0]+"'>"+datas[i][0]+"</td>"+
    	"<td title='"+datas[i][1]+"'>"+datas[i][1]+"</td>"+
    	"<td title='"+datas[i][2]+"'>"+datas[i][2]+"</td>"+
    	"</tr>"
	}
	str +="</table>";
	ranklistRight1.append(str);
}

window.addEventListener("resize", function () {
//  lineChart.resize();
//  pieChart.resize();
    mapChart.resize();
//  barChart.resize();
});
